package org.istt.domain;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * Report entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "TBL_REPORT", schema = "dbo", catalog = "onegate")
public class Report extends BaseObject<Long> implements java.io.Serializable {

	// Fields
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	private Set<Category> categories = new HashSet<Category>(0);
	private Set<Category> categoryVoucher = new HashSet<Category>(0);
	private String description;
	
	private String functionName;
	private Long id;
	private String reportName;
	/** default constructor */
	public Report() {
	}

	public boolean equals(Object o) {
		if (this == o) return true;
		if (!(o instanceof Report)) return false;

		final Report ps = (Report) o;

        if (!getReportName().equals(ps.getReportName())) return false;

		return true;
	}

	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="report")
	public Set<Category> getCategories() {
		return categories;
	}

	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="voucher")
	public Set<Category> getCategoryVoucher() {
		return categoryVoucher;
	}


	@Column(name = "DESCRIPTION", length = 500)
	public String getDescription() {
		return description;
	}

	@Column(name = "FUNCTION_NAME", length = 200)
	public String getFunctionName() {
		return functionName;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}
	
	@Column(name = "REPORT_NAME", length = 500)
	public String getReportName() {
		return reportName;
	}

	@Override
	public int hashCode() {
		int result;
		result = reportName.hashCode();
		result = 29 * result;
		return result;
	}
	public void setCategories(Set<Category> categories) {
		this.categories = categories;
	}

	public void setCategoryVoucher(Set<Category> categoryVoucher) {
		this.categoryVoucher = categoryVoucher;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setFunctionName(String functionName) {
		this.functionName = functionName;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setReportName(String reportName) {
		this.reportName = reportName;
	}
	
	@Override
	public String toString() {
		ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
        .append("categoryName", this.reportName)
		.append("description", this.description);

		return sb.toString();
	}

	
}